package LeetCode.No109;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @author 16778
 * @date 2025/11/19 8:08
 * @description
 */
public class No2154 {
    public int findFinalValue(int[] nums, int original) {
        int n = nums.length;
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            if(nums[i]%original==0){
                set.add(nums[i]);
            }
            while(set.contains(original)){
                original*=2;
            }
        }
        return original;
    }
}
